Skip to content

Conversation

@jnunemaker
Copy link
Owner

When base_uri is configured and a path argument contains an absolute URL with a different host, HTTParty now raises UnsafeURIError instead of sending the request (and any configured headers/credentials) to the unintended host.

This prevents Server-Side Request Forgery (SSRF) attacks where an attacker controlling the path value could redirect requests to malicious servers and capture API keys or other sensitive headers.

The validation can be bypassed with skip_uri_validation: true for legitimate use cases. Redirects are not validated to allow normal redirect flows.

🤖 Generated with Claude Code

…-38w4)

When base_uri is configured and a path argument contains an absolute URL
with a different host, HTTParty now raises UnsafeURIError instead of
sending the request (and any configured headers/credentials) to the
unintended host.

This prevents Server-Side Request Forgery (SSRF) attacks where an attacker
controlling the path value could redirect requests to malicious servers
and capture API keys or other sensitive headers.

The validation can be bypassed with `skip_uri_validation: true` for
legitimate use cases. Redirects are not validated to allow normal
redirect flows.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jnunemaker jnunemaker self-assigned this Dec 23, 2025
@jnunemaker jnunemaker merged commit ddfbc8d into main Dec 23, 2025
12 checks passed
@ashkulz ashkulz mentioned this pull request Dec 24, 2025
@ienev
Copy link

ienev commented Jan 6, 2026

Not sure if anyone has already raised this but this PR still doesn't fix the PoC given here GHSA-hm5p-x4rq-38w4

@walro
Copy link

walro commented Jan 9, 2026

The PoC uses the same host (localhost), but different ports. The implementation only checks the host portion (i.e. no port check) why the PoC still 'works'. Changing the PoC to combine, say, 127.0.0.1 and localhost and it does indeed stop the request. However, I am not sure if ports should also be honored. Unlikely it would be abused, but not impossible I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants